import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
import 'package:laoba_menu/views/product-detail/Detail.dart';

class StepItem extends StatefulWidget {
  StepItem(
      {Key key,
      this.name,
      this.cover,
      this.id,
      this.desc,
      this.cook_id,
      this.index})
      : super(key: key);

  final String name;
  final String cover;
  final int id;
  final String desc;
  final int cook_id;
  int index;
  @override
  StepItemWState createState() => new StepItemWState(
      this.name, this.cover, this.id, this.desc, this.cook_id, this.index);
}

class StepItemWState extends State<StepItem> {
  String name;
  final String cover;
  final int id;
  final String desc;
  int cook_id;
  int index;
  StepItemWState(
      this.name, this.cover, this.id, this.desc, this.cook_id, this.index);
  @override
  Widget build(BuildContext context) {
    double mediaWidth = MediaQuery.of(context).size.width; // 屏幕宽度
    return Container(
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Container(
            padding: const EdgeInsets.fromLTRB(20, 5, 20, 10),
            child: Text(
              "- 步骤 ${index}",
              style:
                  TextStyle(color: Colors.black, fontWeight: FontWeight.bold),
            ),
          ),
          Container(
              margin: const EdgeInsets.all(0),
              padding: const EdgeInsets.fromLTRB(20, 0, 20, 0),
              decoration: BoxDecoration(
                  borderRadius: BorderRadius.all(Radius.circular(10.0))),
              child: ClipRRect(
                borderRadius: BorderRadius.circular(10),
                child: Image(
                  image: NetworkImage(cover),
                  fit: BoxFit.cover,
                  width: mediaWidth - 40,
                ),
              )),
          Container(
            padding: const EdgeInsets.fromLTRB(20, 10, 20, 20),
            child: Text(
              desc,
              style: TextStyle(color: Colors.black87),
            ),
          )
        ],
      ),
    );
  }
}
